package models

import "time"

type BMUBattery struct {
	ID int64 `gorm:"primary_key" json:"id"`
	PointId int `json:"pointId" gorm:"column:point_id"`
	BMUId int `json:"bmuId" gorm:"column:bmu_id"`
	Voltage float64 `json:"vol" gorm:"column:voltage"`
	Soc float64 `json:"soc" gorm:"column:soc"`
	CollTime time.Time `json:"collTime" gorm:"column:coll_time;default:null"`
}

func GetBMUBatteriesByBMUId(bmuId int) (bmuBatteries []BMUBattery) {
	db.Where("bmu_id = ?", bmuId).Find(&bmuBatteries)
	return
}

func AddBMUBattery(pointId, bmuId int, voltage, soc float64) bool {
	db.Create(&BMUBattery{
		PointId: pointId,
		BMUId: bmuId,
		Voltage: voltage,
		Soc: soc,
	})
	return true
}
